package documentooborot.display.servlet;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import documentooborot.display.TestResponseWriter;
import documentooborot.display.ResponseWriter;

public class DODisplayServlet extends HttpServlet
{
	private String response;
	private Map fetchedData;
	private String contenttype;
	private ResponseWriter responseWriter;
	private HttpServletRequest req; 
	private HttpServletResponse resp;
	public DODisplayServlet() {
		super();
		fetchedData=new HashMap();
		response="";
		setContenttype("text/html");
		setResponseWriter(new TestResponseWriter());
	}
	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException{
		this.req=req;
		this.resp=resp;
		fetchData();
		generateResponse();
	}
	protected void fetchData() {
		
	}
	protected void generateResponse() throws IOException {
		resp.getWriter().println(responseWriter.write(fetchedData));
		resp.setContentType(contenttype);
	}
	public void setContenttype(String contenttype) {
		this.contenttype = contenttype;
	}
	public String getContenttype() {
		return contenttype;
	}
	public void setResponseWriter(ResponseWriter responseWriter) {
		this.responseWriter = responseWriter;
	}
	public ResponseWriter getResponseWriter() {
		return responseWriter;
	}
}
